package server.java.autoduel.Cars;

import java.io.Serializable;
import java.nio.ByteBuffer;

import server.java.autoduel.Network.IPacketizable;
import server.java.autoduel.Network.OPCODES;

import com.sun.sgs.app.AppContext;
import com.sun.sgs.app.ManagedObject;

/**
 * Represents a car's powerplant
 * 
 * @author Ian Axelrod
 * @author Liz Ha
 * @author Andrew Muldowney
 * @author Edward Futch
 */
public class PowerPlant implements ManagedObject, Serializable, IPacketizable {
	private static final long serialVersionUID = -3777411909387761699L;

	/**
	 * The name of the powerplant
	 */
	private String name;

	/**
	 * The weight of the powerplant
	 */
	private Integer weight;

	/**
	 * The cost of the powerplant
	 */
	private Integer cost;

	/**
	 * The spaces the powerplant takes up
	 */
	private Integer spaces;

	/**
	 * The power the powerplant generates
	 */
	private Integer power;

	/**
	 * The maximum speed the powerplant allows
	 */
	private Integer maxSpeed;

	/**
	 * Construct a powerplant
	 */
	public PowerPlant(String name, Integer weight, Integer cost,
			Integer spaces, Integer power, Integer maxSpeed) {
		this.name = name;
		this.weight = weight;
		this.cost = cost;
		this.spaces = spaces;
		this.power = power;
		this.maxSpeed = maxSpeed;
	}

	/**
	 * Creates a copy of this powerplant
	 * 
	 * @return a copy of the powerplant
	 */
	public PowerPlant copy() {
		return new PowerPlant(this.name, this.weight, this.cost, this.spaces,
				this.power, this.maxSpeed);
	}

	@Override
	public ByteBuffer encodePacket(OPCODES opcode) {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * @return the cost
	 */
	public Integer getCost() {
		return this.cost;
	}

	/**
	 * @return the maxSpeed
	 */
	public Integer getMaxSpeed() {
		return this.maxSpeed;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * @return the power
	 */
	public Integer getPower() {
		return this.power;
	}

	/**
	 * @return the spaces
	 */
	public Integer getSpaces() {
		return this.spaces;
	}

	/**
	 * @return the weight
	 */
	public Integer getWeight() {
		return this.weight;
	}

	/**
	 * @param cost
	 *            the cost to set
	 */
	public void setCost(Integer cost) {
		AppContext.getDataManager().markForUpdate(this);
		this.cost = cost;
	}

	/**
	 * @param maxSpeed
	 *            the maxSpeed to set
	 */
	public void setMaxSpeed(Integer maxSpeed) {
		AppContext.getDataManager().markForUpdate(this);
		this.maxSpeed = maxSpeed;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		AppContext.getDataManager().markForUpdate(this);
		this.name = name;
	}

	/**
	 * @param power
	 *            the power to set
	 */
	public void setPower(Integer power) {
		AppContext.getDataManager().markForUpdate(this);
		this.power = power;
	}

	/**
	 * @param spaces
	 *            the spaces to set
	 */
	public void setSpaces(Integer spaces) {
		AppContext.getDataManager().markForUpdate(this);
		this.spaces = spaces;
	}

	/**
	 * @param weight
	 *            the weight to set
	 */
	public void setWeight(Integer weight) {
		AppContext.getDataManager().markForUpdate(this);
		this.weight = weight;
	}
}